import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:zchope_student/lesson/lessons.dart';
import 'package:zchope_student/lesson/lessonsonline.dart';
import 'package:zchope_student/login/forget_pwd.dart';
import 'package:zchope_student/login/register.dart';
import 'package:zchope_student/question/commonProblem.dart';
import 'package:zchope_student/shouye/firstdetails.dart';
import 'package:zchope_student/user/userdata.dart';

import 'login/login.dart';
import 'login/loginmain.dart';
import 'main/course.dart';
import 'main/mainpage.dart';
import 'main.dart';
import 'myimagepicker.dart';
import 'pass/changepass.dart';
import 'player/myijkplayer.dart';
import 'user/userbind.dart';

class Routes {
  static FluroRouter router;
  static String rootPage = '/';
  static String login = '/login';
  static String loginMain = '/loginMain';
  static String mainPage = '/mainPage';
  static String myImagePicker = '/myImagePicker';
  static String changePass = '/changePass';
  static String register = '/register';
  static String forget_pwd = '/forget_pwd';
  static String userData = '/userData';
  static String userinfo = '/userinfo';
  static String commonProblem = '/commonProblem';
  static String course = '/course';
  static String firstdetails = '/firstdetails';
  static String qrReader = '/qrReader';
  static String myIjkPlayer = '/myIjkPlayer';
  static String lessons = '/scan/lessons';
  static String lessonsOnline = '/scan/lessonsonline';
  static String userBind = '/user/userbind';

  static var courseHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Course();
  });
  static var lessonHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Lessons();
  });

  static var myIjkPlayerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String url = params['url']?.first;
    return MyIjkPlayer(
      url: url,
    );
  });
  static var loginHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Login();
  });

  static var loginMainHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoginMain();
  });
  static var userDataHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return UserData();
  });
  static var userBindHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return UserBind();
  });
  static var firstdetailsHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return FirstDetails();
  });

  static var commonProblemHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return CommonProblem();
  });

  static var registerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Register();
  });

  static var changePassHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ChangePass();
  });

  static var forget_pwdHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ForgetPwd();
  });

  static var mainPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MainPage();
  });
  static var lessonsonlinePageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LessonsOnline();
  });

  static var myImagePickerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String type = params["type"]?.first;
    return MyImagePicker(type: type);
  });

  static void configureRoutes(FluroRouter router) {
    router.define(rootPage,
        handler: Handler(handlerFunc: (context, params) => PageRoot()));

    router.define(changePass, handler: changePassHandler);
    router.define(forget_pwd, handler: forget_pwdHandler);
    router.define(login, handler: loginHandler);
    router.define(loginMain, handler: loginMainHandler);
    router.define(register, handler: registerHandler);
    router.define(mainPage, handler: mainPageHandler);
    router.define(myImagePicker, handler: myImagePickerHandler);
    router.define(userData, handler: userDataHandler);
    router.define(userBind, handler: userBindHandler);
    router.define(commonProblem, handler: commonProblemHandler);
    router.define(course, handler: courseHandler);
    router.define(firstdetails, handler: firstdetailsHandler);
    router.define(lessons, handler: lessonHandler);
    router.define(myIjkPlayer, handler: myIjkPlayerHandler);
    router.define(lessonsOnline, handler: lessonsonlinePageHandler);
    Routes.router = router;
  }
}
